﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufBase.h"
#include "GnufPallet.h"
#include "GnufInfo.h"
#include "GnufItemEvents.h"
#include "GnufFamilyTypes.h"

namespace gnuf
{
    class QtOriginColorPicker;
    class Color;
    class Toolbar;
    class ButtonAppearanceSetting;

    class GNUF_BASE_EXPORT ColorPicker final: public gnuf::IPalletEventHandler, public gnuf::IItemEventHandler
    {
    public:
        virtual ~ColorPicker();

        static ColorPicker* getInstance();
    public:
        void show(bool synchronously);
        void close();
        void setColor(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a = 255);
        Color color();
        void enableAlphaChannel(bool enable);
        bool isAlphaChannelEnabled() const;

        Toolbar* getToolBar() { return m_toolbar.get(); }
        std::vector<gcmp::OwnerPtr<FamilyTypeButton>>& getButtons() { return m_buttons; }
        const ButtonAppearanceSetting* getButtonAppearanceSetting() { return m_buttonAppearanceSetting.get(); }

    public:
        // Inherits from gnuf::IPalletEventHandler...
        virtual void onHeaderTabChanged(Pallet*);

    private:
        ColorPicker();

        QtOriginColorPicker* m_qtItem;
        bool m_enableAlphaChannel;
        gcmp::OwnerPtr<Pallet> m_pallet;
        gcmp::OwnerPtr<Toolbar> m_toolbar;
        std::vector<gcmp::OwnerPtr<FamilyTypeButton>> m_buttons;
        gcmp::OwnerPtr<ButtonAppearanceSetting> m_buttonAppearanceSetting;
    };
}
